// 主界面
;
define(function(require, exports, module) {
	'use strict';
	var util = require("util");
	var base = require("base");
	var router = require("../hash/pageRouter");
	var dialog = require("dialog");
	var validate = require("validate");
	var databind = require("databind");
	var html_inventoryDetail = require("./html_inventoryDetail.html");
	var html_signed_detail_information = require("../main/html_signed_detail_information.html");
	var css_detail_info = require("./financingDetailInfo.css");
	var css_financingDetail_receivablesNotice = require("./financingDetail_receivablesNotice.css");
	var js_detail_info = require("./financingDetailInfo.js");
	var html_financingDetail_recieveNotice = require("./financingDetail_recieveNotice1.html");
	var html_financingDetail_tallyList = require("./financingDetail_tallyList.html");
	var html_financingDetail_financeContract = require("./financingDetail_financeContract.html");
	var html_financeWaybill = require("./html_financeWaybill.html");
	var html_financingDetail_bulkstockInventory = require("./financingDetail_bulkstockInventory.html");
	var html_financingDetail_pickup = require("./financingDetail_pickup.html");
	var html_financingDetail_loanNotice = require("./financingDetail_loanNotice.html");
	var html_financingDetail_supervisionContract = require("./financingDetail_supervisionContract.html");
	var html_financingDetail_supervisionInform = require("./financingDetail_supervisionInform.html");
	var html_financingDetail_receivablesNotice = require("./financingDetail_receivablesNotice.html");
	var html_financingDetail_SupervisionConfirmation = require("./financingDetail_SupervisionConfirmation.html");
	var html_transport_notice = require("./html_transport_notice.html");
	var html_delivery_notice = require("./html_delivery_notice.html");
	var html_audit_detail = require("./html_aduit_detail.html");
	var html_supervision_endall = require("./html_supervision_endall.html");
	var financingDetail_relieve = require("./financingDetail_relieve.html");
	var financingDetail_sign = require("./financingDetail_sign.html");
	var css_financingDetailDynamic = require("./financingDetailDynamic.css");
	var constant = require("constant");
	var storage = window.sessionStorage;
	var dataFinancingDetail;
	var tools = require("tools");
	var pageIndex = 1,
		pageSize = 10,
		totalPageCount = 1,
		totalRecordCount = 0; //分页初始化
	var financeId = "";
	var financeState;
	var fid;

	var init = function(page) {
		financeId = page.params.financeId || base.getUrlParam("financeId");
		financeState = page.params.financeState || base.getUrlParam("financeState");
		initEvent();
		js_detail_info.init(page);
		showFinancingDetailDynamic();
		router.init();
		initCss();
	};

	var initEvent = function() {
		//若未登录，则返回登陆页面
		if (base.getData("sid") == null || base.getData("sid") == "" || base.getData("sid") == undefined) {
			top.location.href = "../login/login.html";
		}

		//点击显示提单号
		$(".platformBtns").on("click", ".button-submit-financeWaybill", function() {
			$("#popdialog").html(html_financeWaybill);
			dialog.showDialog($("#financeWaybill_dialog"), function() {});
			databind.fillForm($("#financeWaybill_dialog"), {
				financeId: financeId
			});
			inquireFinanceWaybillList();

		});
	};

	//查询融资信息的提单号
	var inquireFinanceWaybillList = function() {
		base.fnAjax({
			action: "inquireFinanceWaybillList.json",
			version: "v1.0",
			oData: {
				financeId: financeId
			}, //传递参数
			fnSuccess: function(data) { //成功回调
				if (data.status == 200) {
					var tpl;

					if (data.datas.length > 0) {
						tpl = $("#WaybillContent1").html();
						var html = juicer(tpl, data);
						$(".WaybillContent").html(html);
					} else {
						tpl = $("#WaybillContent").html();
						$(".WaybillContent").html(tpl);
					}

					databind.fillForm($(".WaybillContent"), {
						bookingSpaceNumber: dataFinancingDetail.datas[0].bookingSpaceNumber
					});
				} else {
					base.alert(3, data.message);
				}
			}
		});
	};

	var initCss = function() {
		//		$(".d2").css("background", "url(../../../res/png/tab_bg3.png) 17% 100% no-repeat");
		$(".financeDetailInfo").css("color", "#000000");
		$(".financingDetailDynamic").css("color", "#FF7344");
	}

	//查询放货通知
	var inquireRecieveNoticeDetail = function(recieveNoticeId) {
		base.fnAjax({
			action: "inquireRecieveNoticeDetail.json",
			async: false,
			oData: {
				recieveNoticeId: recieveNoticeId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					$("#popdialog").html(html_financingDetail_recieveNotice);
					dialog.showDialog($("#recieveNotice_dialog1"));
					var tpl1 =  $("#bookingSpaceTpl1").html();
					databind.fillInput($("#recieveNotice_dialog1"), {
						action: "inquireRecieveNoticeDetail.json?recieveNoticeId=" + recieveNoticeId,
						version: "v1.0"
					});
					var tpl = $("#financingDetail-bulkstock").html();
					var html = juicer(tpl, data.datas[0]);
					$(".recieveNoticeTable").html(html);
					loadLogisticsCompanyPageList("supervisionCompanyName", "supervisionTpl");
					
					base.fnAjax({
						action: "inquireFinanceApplicationDetail.json",
						async: false,
						oData: {
							financeId: financeId
						}, //传递参数
						fnSuccess: function(data) {
							if (data.status == 200) {
								juicer.register("getValueByKey", constant.getValueByKey);
								var html1 = juicer(tpl1, data);
								$(".recieveNoticeTable").append(html1);
							} else {
								base.alert(2, "信息获取失败");
							}
						}
					});
					
					$("#recieveNotice_dialog1 .dialogHandlerBtn").unbind("click").click(function(){
						dialog.hideDialog($("#recieveNotice_dialog1"));
					});
					
					databind.disableInput($("#recieveNotice_dialog1"));
				} else {
					base.alert(2, "信息获取失败");
				}
			}
		});
	};

	//查询理货清单
	var inquireTallyingDetail = function(tallyingId) {
//		storage.setItem("financeId", financeId);
//		base.openUrl("../financing/financingManage.html#bulkstockListing/accountBulkstockListing.html", "new");
		router.route("bulkstockListing/tallyingDetailInfo.html?tallyingId=" + tallyingId)
	};

	//获取提货申请明细
	var inquirePickupApplicationDetail = function(pickupId) {
		base.fnAjax({
			action: "inquireNormalPickupApplicationDetail.json",
			async: false,
			oData: {
				pickupId: pickupId,
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					$("#popdialog").html(html_financingDetail_pickup);
					var pickup_dialog = $("#pickup_dialog");
					dialog.showDialog(pickup_dialog, function() {});
					databind.fillInput($("#pickup_dialog"), {
						action: "inquireNormalPickupApplicationDetail.json?pickupId=" + pickupId
					});
					var tpl = $("#pickupListTpl").html();
					var html = juicer(tpl, data);
					$(".pickupListBody").html(html);
					if (financeState == 14) {
						if (data.datas[0].exchangeAmount + data.datas[0].receivedAmount < data.datas[0].auditAmount) {
							$(".footerBtn1").addClass("none");
							$(".footerBtn").addClass("none");
							$(".footerBtn2").addClass("none");
							$(".footerBtn3").removeClass("none");
						}
					} else if (financeState == 10 || financeState == 12) {
						$(".footerBtn1").addClass("none");
						$(".footerBtn3").addClass("none");
						$(".footerBtn2").addClass("none");
						$(".footerBtn").removeClass("none");
					} else if (financeState == 15) {
						$(".footerBtn").addClass("none");
						$(".footerBtn2").addClass("none");
						$(".footerBtn3").addClass("none");
						$(".footerBtn1").removeClass("none");
					} else {
						$(".footerBtn1").addClass("none");
						$(".footerBtn3").addClass("none");
						$(".footerBtn2").addClass("none");
						$(".footerBtn").addClass("none");
					}

					$("#sure_no_pickup").unbind("click").click(function() {
						$(".page-content-main").addClass("none");
						$(".page-content-main3").removeClass("none");
						$(".footerBtn").addClass("none");
						$(".footerBtn1").addClass("none");
						$(".footerBtn3").addClass("none");
						$(".footerBtn2").removeClass("none");
						$("#sure_confirm").unbind("click").click(function() {
							databind.submitDom($(".page-content-main3"));
							dialog.hideDialog(pickup_dialog);
						});
						$("#sure_cancel").unbind("click").click(function() {
							$(".page-content-main3").addClass("none");
							$(".page-content-main").removeClass("none");
							$(".footerBtn2").addClass("none");
							$(".footerBtn").removeClass("none");
						});
					});

					$("#sure_yes_pickup").unbind("click").click(function() {
						$(".page-content-main").addClass("none");
						$(".page-content-main2").removeClass("none");
						$(".footerBtn").addClass("none");
						$(".footerBtn2").removeClass("none");
						$("#sure_confirm").unbind("click").click(function() {
							if ($.trim($("#auditAmount").val()) == "" || $.trim($("#auditAmount").val()) == null) {
								base.alert(2, "请输入审核金额！");
							} else {
								databind.submitDom($(".page-content-main2"));
								dialog.hideDialog(pickup_dialog);
							}
						});
						$("#sure_cancel").unbind("click").click(function() {
							$(".page-content-main2").addClass("none");
							$(".page-content-main").removeClass("none");
							$(".footerBtn2").addClass("none");
							$(".footerBtn1").addClass("none");
							$(".footerBtn").removeClass("none");
						});
					});
					//点击放货通知
					$("#sure_yes_deliveryNotice").unbind("click").click(function() {
						$(".page-content-main").addClass("none");
						$(".page-content-main4").removeClass("none");
						$(".footerBtn1").addClass("none");
						$(".footerBtn2").removeClass("none");
						databind.fillForm($("#pickup_dialog"), {
							pickupId: pickupId
						});
						loadLogisticsCompanyPageList("logisticsCompanyName", "logisticsTpl");
						$("#sure_confirm").unbind("click").click(function() {
							databind.submitDom($("#deliveryNotice-content"), function() {
								base.alert(1, "下发放货通知成功");
								dialog.hideDialog(pickup_dialog);
								router.route("financing/financingDetailDynamic.html?financeId=" + financeId + "&financeState=" + financeState, true);
							});
						});
					});

					//收款 
					$("#receiveAmount").unbind("click").click(function() {
						$(".page-content-main").addClass("none");
						$(".page-content-main5").removeClass("none");
						$(".footerBtn3").addClass("none");
						$(".footerBtn2").removeClass("none");
						$("#sure_cancel").unbind("click").click(function() {
							$(".page-content-main5").addClass("none");
							$(".page-content-main").removeClass("none");
							$(".footerBtn2").addClass("none");
							$(".footerBtn3").removeClass("none");
						});
						$("#sure_confirm").unbind("click").click(function() {
							databind.submitDom($("#receivables"), function() {
								base.alert(1, "创建收款成功");
								router.route("financing/financingDetailDynamic.html?financeId=" + financeId + "&financeState=" + financeState, true);
							});
						});
					});
				} else {
					//base.alert(2,"信息获取失败");
				}
			}
		});
	};
	
	//监管解除通知
	var inquireRelieveSupervisionDetail = function(inventoryId) {
		base.fnAjax({
			action: "inquireBulkstockInventoryDetail.json",
			async: false,
			oData: {
				inventoryId: inventoryId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					$("#popdialog").html(financingDetail_relieve);
					dialog.showDialog($("#relieve_dialog"));
					databind.fillForm($("#relieve_dialog"), data.datas[0]);
					var tpl = $("#bulkstockInventoryListTpl").html();
					var html = juicer(tpl, data);
					$(".bulkstockInventoryBody").html(html);
					databind.disableInput($("#relieve_dialog"));
					$("#relieve_dialog .dialogHandlerBtn").unbind("click").click(function(){
						dialog.hideDialog($("#relieve_dialog"));
					});
				} else {
					base.alert(2, "信息获取失败");
				}
			}
		});
	};

	//查询箱货明细
	var inquireBulkstockInventoryDetail = function(inventoryId) {
		base.fnAjax({
			action: "inquireBulkstockInventoryDetail.json",
			async: false,
			oData: {
				inventoryId: inventoryId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					$("#popdialog").html(html_financingDetail_bulkstockInventory);
					var bulkstockInventory_dialog = $("#bulkstockInventory_dialog");
					dialog.showDialog(bulkstockInventory_dialog, function() {
						dialog.hideDialog(bulkstockInventory_dialog);
					});
					databind.fillForm($("#bulkstockInventory_dialog"), data.datas[0]);
					var tpl = $("#bulkstockInventoryListTpl").html();
					var html = juicer(tpl, data);
					$(".bulkstockInventoryBody").html(html);
					databind.disableInput($("#bulkstockInventory_dialog"));
				} else {
					base.alert(2, "信息获取失败");
				}
			}
		});
	};
	
	//查询签收单
	var inquireSignatureForm = function(inventoryId) {
		base.fnAjax({
			action: "inquireBulkstockInventoryDetail.json",
			async: false,
			oData: {
				inventoryId: inventoryId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					$("#popdialog").html(financingDetail_sign);
					dialog.showDialog($("#sign_dialog"));
					databind.fillForm($("#sign_dialog"), data.datas[0]);
					var tpl = $("#bulkstockInventoryListTpl").html();
					var html = juicer(tpl, data);
					$(".bulkstockInventoryBody").html(html);
					
					//签收前图片
					$.each($("#sign_dialog input[name=signPreFile]").val().split(','), function() {
						var str = '<a target="_blank" href="/finance/api/v1.0/downloadFile.file?fileUuid='+ this +'"><img alt="签收前图片" src="/finance/api/v1.0/downloadFile.file?fileUuid='+ this +'" /></a>';
						$("#sign_dialog input[name=signPreFile]").after(str);
					});
					
					//签收后图片
					$.each($("#sign_dialog input[name=signSuffixFile]").val().split(','), function() {
						var str = '<a target="_blank" href="/finance/api/v1.0/downloadFile.file?fileUuid='+ this +'"><img alt="签收前图片" src="/finance/api/v1.0/downloadFile.file?fileUuid='+ this +'" /></a>';
						$("#sign_dialog input[name=signSuffixFile]").after(str);
					});
					
					databind.disableInput($("#sign_dialog"));
					$("#sign_dialog .dialogHandlerBtn").unbind("click").click(function(){
						dialog.hideDialog($("#sign_dialog"));
					});
				} else {
					base.alert(2, "信息获取失败");
				}
			}
		});
	};

	//监管通知获取监管合同和监管物流
	var inquireSupervisionContractToSupervisionNotice = function() {
		base.fnAjax({
			action: "inquireFinanceSupervisionContract.json",
			oData: {
				financeId: financeId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					databind.fillForm(".supervisionInformContent", data.datas[0]);

				} else {
					base.alert(2, "信息获取失败");
				}
			}
		});
	};

	//查看监管通知
	var inquireSupervisionNoticeDetail = function(supervisionNoticeId) {

		$("#popdialog").html(html_financingDetail_supervisionInform);
		var supervisionInform_dialog = $("#supervisionInform_dialog");
		dialog.showDialog(supervisionInform_dialog, function() {});

		base.fnAjax({
			action: "inquireFinanceApplicationDetail.json",
			async: false,
			oData: {
				financeId: financeId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					var tpl = $("#supervisionInform").html();
					var html = juicer(tpl, data);
					$(".supervisionInformContent").html(html);
					inquireSupervisionContractToSupervisionNotice();
					inquireFinanceSupervisionNotice(data);
					databind.disableInput($("#supervisionInform_dialog"));
					$("#sure_yes").remove();
				} else {
					base.alert(2, "信息获取失败");
				}
			}
		});
	}

	//查看融资监管通知信息
	var inquireFinanceSupervisionNotice = function(dataFinancingDetail) {
			base.fnAjax({
				action: "inquireFinanceSupervisionNotice.json",
				oData: {
					financeId: financeId
				}, //传递参数
				fnSuccess: function(data) {
					if (data.status == 200) {
						databind.fillForm(".supervisionInformContent", dataFinancingDetail.datas[0]);
						if (data.datas.length > 0 && data.datas[0].supervisionNoticeId != 0) {
							databind.fillForm(".supervisionInformContent", data.datas[0]);

							$(".supervisionInformContent").attr("action", "updateSupervisionNotice");
						}

					} else {
						base.alert(2, "信息获取失败");
					}
				}
			});
		}
		//查询监管合同信息
	var inquireSupervisionContractDetail = function(supervisionContractId) {
		$("#popdialog").html(html_financingDetail_supervisionContract);
		var supervisionContract_dialog = $("#supervisionContract_dialog");
		dialog.showDialog(supervisionContract_dialog, function() {});
		loadLogisticsCompanyPageList("supervisionCompanyName", "supervisionTpl");
		base.fnAjax({
			action: "inquireSupervisionContractDetail.json",
			async: false,
			oData: {
				supervisionContractId: supervisionContractId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {

					databind.fillForm(".supervisionContractContent_submit", data.datas[0]);
					var str = $("#materials").val().split(",");
					$.each(str, function(i, s) {
						$(".uploadImgP").parent().append('<a style="display:inline-block;" target="_blank" href="/finance/api/v1.0/downloadFile.file?fileUuid=' + s + '"><img style="width: 100px; height: 100px; display: inline-block;" src="../../../res/png/file_icon.png" /><br /><span class="contactFileName">' + tools.inquireFile(s) + '</span></a>');
					});
					databind.disableInput($("#supervisionContract_dialog"));
					$("#sure_yes").remove();
					$(".uploadImgP").css("display", "none");
				} else {
					base.alert(2, "信息获取失败");
				}
			}
		});
	}



	//查询融资合同信息
	var inquireFinanceContractDetail = function(financeContractId) {
		base.fnAjax({
			action: "inquireFinanceContractDetail.json",
			async: false,
			oData: {
				financeContractId: financeContractId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					$("#popdialog").html(html_financingDetail_financeContract);
					var financeContract_dialog = $("#financeContract_dialog");
					dialog.showDialog(financeContract_dialog, function() {
						dialog.hideDialog(financeContract_dialog);
					});
					databind.fillInput($("#financeContract_dialog"), {
						action: "inquireFinanceContractDetail.json?financeContractId=" + financeContractId,
						version: "v1.0",
						async: false
					});
					var str = $("#materials").val().split(",");
					$.each(str, function(i, s) {
						$(".uploadImgP").parent().append('<a style="display:inline-block;" target="_blank" href="/finance/api/v1.0/downloadFile.file?fileUuid=' + s + '"><img style="width: 100px; height: 100px; display: inline-block;" src="../../../res/png/file_icon.png" /><br/><span class="contactFileName">' + tools.inquireFile(s) + '</span></a>');
					});
					databind.disableInput($("#financeContract_dialog"));
					$("#sure_yes").remove();
					$(".uploadImgP").css("display", "none");
				} else {
					base.alert(2, "信息获取失败");
				}
			}
		});
	};

	//获取放款通知明细
	var linkToInventoryDetail = function(inventoryId) {
		router.route("financing/deliveryNoticeDetail.html?deliveryNoticeId=" + inventoryId);
	};

	//获取放款通知明细
	var inquireLoanNoticeDetail = function(loanNoticeId) {
//		$("#popdialog").html(html_financingDetail_loanNotice);
//		var loanNotice_dialog = $("#loanNotice_dialog");
//		dialog.showDialog(loanNotice_dialog, function() {
//			dialog.hideDialog(loanNotice_dialog);
//		});
//
//		databind.fillInput($("#loanNotice_dialog"), {
//			action: "inquireLoanNoticeDetail.json?loanNoticeId=" + loanNoticeId,
//			version: "v1.0",
//			async: false
//		});
//		inquireWaitLoanNoticeBulkstockInventoryList();
//		databind.disableInput($("#loanNotice_dialog"));
//		//		$("#sure_yes_loanNotice").css("display","none");
		router.route("financing/loanNotice.html?loanNoticeId=" + loanNoticeId);
	};

	//查询理货任务列表
	var inquireWaitLoanNoticeBulkstockInventoryList = function() {
		base.fnAjax({
			action: "inquireWaitLoanNoticeBulkstockInventoryList.json",
			async: false,
			oData: {
				financeId: financeId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					var tpl = $("#bulkstockLoanNoticeTpl").html();
					var html = juicer(tpl, data);
					$("#bulkstockLoanNoticeListBody").html(html);

					$.each($(".evaluateValuations"), function(i, val) {
						var evaluateValuations = 0;
						$.each($(this).parent().find(".evaluateValuation"), function(i, val) {
							evaluateValuations = evaluateValuations + parseFloat($(this).html());
						});
						$(this).html(evaluateValuations);
					});


				} else {
					base.alert(2, "信息获取失败");
				}
			}
		});
	}

	//企业查询融资信息详情
	var showFinancingDetailDynamic = function() {
		base.fnAjax({
			action: "inquireFinanceProcessList.json",
			async: false,
			oData: {
				financeId: financeId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					dataFinancingDetail = data;
					juicer.register("getValueByKey", constant.getValueByKey)
					var tpl = $("#accountProcessTpl").html();
					var html = juicer(tpl, data);
					$("#accountProcessBody").html(html);
					if ($(".div1 div").html() == null) {
						$(".div1").append('<p class="div11"><span class="span1">未开始</span><span class="span2"></span><span class="span3"></span><span class="span4"></span></p>');
					}
					if ($(".div2 div").html() == null) {
						$(".div2").append('<p class="div11"><span class="span1">未开始</span><span class="span2"></span><span class="span3"></span><span class="span4"></span></p>');
					}
					if ($(".div3 div").html() == null) {
						$(".div3").append('<p class="div11"><span class="span1">未开始</span><span class="span2"></span><span class="span3"></span><span class="span4"></span></p>');
					}
					if ($(".div4 div").html() == null) {
						$(".div4").append('<p class="div11"><span class="span1">未开始</span><span class="span2"></span><span class="span3"></span><span class="span4"></span></p>');
					}
					changeProcessColor();

					$(".pickup").unbind("click").click(function() {
						if ($(this).parent().parent().next(".logistics_info2").css('display') == 'none') {
							$(this).parent().parent().next(".logistics_info2").css('display', 'block');
							$(this).html('收起<img src="../../../res/png/arrow8_icon.png">');
						} else if ($(this).parent().parent().next(".logistics_info2").css('display') == 'block') {
							$(this).parent().parent().next().css('display', 'none');
							$(this).html('展开<img src="../../../res/png/arrow1_icon.png">');
						}
					});

					$(".businessType").unbind("click").click(function() {
						var businessType = $(this).attr("businessType");
						var businessId = $(this).attr("businessId");
						fid = $($(this)).attr("financeId");
						showNotice(businessType, businessId, $(this).html());
					});
				} else {
					base.alert(2, "信息获取失败");
				}
			}
		});
	};

	var showNotice = function(businessType, businessId, v) {
		if (businessType == 1) {
			inquireSupervisionEndall(businessId);
		} else if (businessType == 2) {
			inquireFinanceAuditDetail(businessId);
		} else if (businessType == 3) {
			inquireFinanceContractDetail(businessId);
		} else if (businessType == 4) {
			inquireSupervisionContractDetail(businessId);
		} else if (businessType == 5) {
			inquireSupervisionNoticeDetail(businessId);
		} else if (businessType == 6) {
			inquireRecieveNoticeDetail(businessId);
		} else if (businessType == 7) {
			inquireTallyingDetail(businessId);
		} else if (businessType == 8) {
			inquireLoanNoticeDetail(businessId);
		} else if (businessType == 9) {
			inquireTransportNoticeDetail(businessId);
		} else if (businessType == 10) {
			inquirePickupApplicationDetail(businessId);
		} else if (businessType == 11) {
			inquireReceivablesNoticeDetail(businessId);
		} else if (businessType == 12) {
			linkToInventoryDetail(businessId);
		} else if (businessType == 13) {
			inquireDeliveryDetail(businessId);
		} else if (businessType == 14) {

		} else if (businessType == 15) {
			if (v == "《签收单》") {
				inquireBulkstockInventoryDetail2(businessId);
			} else {
				inquireBulkstockInventoryDetail1(businessId);
			}
		} else if (businessType == 16) {
			inquireSupervisionConfirmationDetail(businessId);
		} else if (businessType == 17) {
			inquireRelieveSupervisionDetail(businessId);
		} else {

		}
	};
	
	//获取签收信息明细
	var inquireBulkstockInventoryDetail2 = function(inventoryId) {
		base.fnAjax({
			action: "inquireBulkstockInventoryDetail.json",
			async: false,
			oData: {
				inventoryId: inventoryId
			}, //传递参数
			fnSuccess: function(data) {
				if (data.status == 200) {
					$("#popdialog").html(html_signed_detail_information);
					var tpl = $("#sigendDetailTpl").html();
					var html = juicer(tpl, data);
					$("#sigendDetailBody").html(html);
					var signPreFile = data.datas[0].signPreFile.split(',');
					var signSuffixFile = data.datas[0].signSuffixFile.split(',');
					$.each(signPreFile, function() {
						$("#signed_detail_dialog .signPreFile").append("<a target='_blank' href='/finance/api/v1.0/downloadFile.file?fileUuid=" + this + " '><img src='/finance/api/v1.0/downloadFile.file?fileUuid=" + this + " '/></a>")
					});
					$.each(signSuffixFile, function() {
						$("#signed_detail_dialog .signSuffixFile").append("<a target='_blank' href='/finance/api/v1.0/downloadFile.file?fileUuid=" + this + " '><img src='/finance/api/v1.0/downloadFile.file?fileUuid=" + this + " '/></a>")
					});
					
					tools.showLogisticsTrajectory(data.datas[0].caseNumber, data.datas[0].waybillNumber, $("#signed_detail_dialog .logisticsDetailInfo"));
					
					dialog.showDialog($("#signed_detail_dialog"));
				} else {
					base.alert(2, "信息获取失败");
				}
			}
		});
	};

	//质押终结通知
	var inquireSupervisionEndall = function(financeId) {
		$("#popdialog").html(html_supervision_endall);
		dialog.showDialog($("#supervision_endall_dialog"));
		base.fnAjax({
			action: "inquireSupervisionEndall.json",
			oData: {
				financeId: financeId
			}, //传递参数
			fnSuccess: function(data) { //成功回调
				if (data.status == 200) {
					var tpl = $("#supervision_endall_dialog .tpl").html();
					var html = juicer(tpl, data);
					$("#supervision_endall_dialog .dialogContent").html(html);
					databind.disableInput($("#supervision_endall_dialog"));
				} else {
					base.alert(3, data.message);
				}
			}
		});
		$("#supervision_endall_dialog").on("click", ".sure_yes", function() {
			dialog.hideDialog($("#supervision_endall_dialog"));
		});
	};

	//配送单
	var inquireDeliveryDetail = function(deliveryId) {
		$("#popdialog").html(html_delivery_notice);
		dialog.showDialog($("#delivery_notice_dialog"));
		base.fnAjax({
			action: "inquireDeliveryDetail.json",
			oData: {
				deliveryId: deliveryId
			}, //传递参数
			fnSuccess: function(data) { //成功回调
				if (data.status == 200) {
					var tpl = $("#delivery_notice_dialog .tpl").html();
					var html = juicer(tpl, data);
					$("#delivery_notice_dialog .dialogContent").html(html);
					databind.disableInput($("#delivery_notice_dialog"));
				} else {
					base.alert(3, data.message);
				}
			}
		});
		$("#delivery_notice_dialog").on("click", ".sure_yes", function() {
			dialog.hideDialog($("#delivery_notice_dialog"));
		});
	};
	
	//箱货详情
	var inquireBulkstockInventoryDetail1 = function(inventoryId){
		$("#popdialog").html(html_inventoryDetail);
		tools.loadList("inquireBulkstockInventoryDetail.json?inventoryId="+inventoryId ,$("#dialog_inventoryDetail .dialogContent"), $("#dialog_inventoryDetail .tpl"), {}, function(){
			$.each($("#dialog_inventoryDetail .fileUuid input").val().split(','), function(){
				if ($.trim(this) != "") {
					$("#dialog_inventoryDetail .fileUuid").append("<a target='_blank' href='/finance/api/v1.0/downloadFile.file?fileUuid="+this+"'>"+tools.inquireFile(this)+"</a>");
				}
			});
		}, null);
		dialog.showDialog($("#dialog_inventoryDetail"));
		
		$("#dialog_inventoryDetail .sure_yes").unbind("click").click(function(){
			dialog.hideDialog($("#dialog_inventoryDetail"));
		});
	};
	
	//运输通知
	var inquireTransportNoticeDetail = function(recieveNoticeId) {
		$("#popdialog").html(html_transport_notice);
		dialog.showDialog($("#transport_notice_dialog"));
		base.fnAjax({
			action: "inquireTransportNoticeDetail.json",
			oData: {
				recieveNoticeId: recieveNoticeId
			}, //传递参数
			fnSuccess: function(data) { //成功回调
				if (data.status == 200) {
					var tpl = $("#transport_notice_dialog .tpl").html();
					var html = juicer(tpl, data);
					$("#transport_notice_dialog .dialogContent").html(html);

				} else {
					base.alert(3, data.message);
				}
			}
		});
		$("#inquireTransportNoticeDetail").on("click", ".sure_yes", function() {
			dialog.hideDialog($("#inquireTransportNoticeDetail"));
		});
	};

	//融资评审信息
	var inquireFinanceAuditDetail = function(financeAuditId) {
		$("#popdialog").html(html_audit_detail);
		dialog.showDialog($("#aduit_detail_dialog"));
		base.fnAjax({
			action: "inquireFinanceAuditDetail.json",
			oData: {
				financeAuditId: financeAuditId
			}, //传递参数
			fnSuccess: function(data) { //成功回调
				if (data.status == 200) {
					var tpl = $("#aduit_detail_dialog .tpl").html();
					var html = juicer(tpl, data);
					$("#aduit_detail_dialog .dialogContent").html(html);
					var materialsId = $("#materials input").val();
					showImg("#showImg", materialsId);
					$(".sure_yes").unbind("click").click(function() {
						dialog.hideDialog($("#aduit_detail_dialog"));
					});
					
					$.each($("#aduit_detail_dialog .field-textarea3"), function() {
						var $this = $(this);
						if ($.trim($this.html()) == "") {
							$this.parent().find("span").html("未审核");
						}
					});					
				} else {
					base.alert(3, data.message);
				}
			}
		});
	};
	
	//监管确认书
	var inquireSupervisionConfirmationDetail = function(confirmationId) {
		$("#popdialog").html(html_financingDetail_SupervisionConfirmation);
		var supervisionConfirmation_dialog = $("#supervisionConfirmation_dialog");
		dialog.showDialog(supervisionConfirmation_dialog, function() {});
		base.fnAjax({
			action: "inquireSupervisionConfirmationDetail.json",
			version: "v1.0",
			async: false,
			oData: {
				confirmationId: confirmationId
			}, //传递参数
			fnSuccess: function(data) { //成功回调
				if (data.status == 200) {
					var tpl = $("#supervisionConfirmationTpl").html();
					var html = juicer(tpl, data);
					$(".supervisionConfirmation").html(html);

				} else {
					base.alert(3, data.message);
				}
			}
		});
	};
	//收款弹出框
	var inquireReceivablesNoticeDetail = function(receivablesId) {
			$("#popdialog").html(html_financingDetail_receivablesNotice);
			var receivablesNotice_dialog = $("#receivablesNotice_dialog");
			dialog.showDialog(receivablesNotice_dialog, function() {
				dialog.hideDialog(receivablesNotice_dialog);
			});

			databind.fillInput($("#receivablesNotice_dialog"), {
				action: "inquireReceivablesDetail.json?receivablesId=" + receivablesId,
				version: "v1.0",
				async: false
			});
			databind.disableInput($("#receivablesNotice_dialog"));
			showImg($(".loan_info4"), $("#fileUuids").val());
		}
		//显示图片
	var showImg = function(dom, fileUuid) {
			if (fileUuid.length == 0) {
				return;
			}
			var fileUuids = fileUuid.split(",");
			var html = "";
			var imgSrc = "";
			for (var i = 0; i < fileUuids.length; i++) {
				imgSrc = fileUuids[i];
				var fileName = tools.inquireFile(imgSrc);
				if (imgSrc.length != 0) {
					html = '<a target="_Blank" href="/finance/api/1.0/downloadFile.file?fileUuid=' + imgSrc + '">';
					html += '<div class="finance-file" id="' + imgSrc + '">';
					html += '<img  src="../../../res/png/file_icon.png" class="finance-field-img"  alt="' + imgSrc + '" />';
					html += '<div class="fileName">'+ fileName +'</div></div></a>';

					$(dom).append(html);
				}

			}
		}
		//获取物流方
	var loadLogisticsCompanyPageList = function(bodyDomId, jsTpl) {
		base.fnAjax({
			action: "inquireLogisticsCompanyListByCompanyName.json",
			version: "v1.0",
			async: false,
			oData: {
				pageIndex: 1,
				pageSize: 50
			}, //传递参数
			fnSuccess: function(data) { //成功回调
				if (data.status == 200) {
					var tpl = $("#" + jsTpl).html();
					var html = juicer(tpl, data);
					$("#" + bodyDomId).html(html);

				} else {
					base.alert(3, data.message);
				}
			}
		});

		//下发运输通知   绑定点击物流方事件
		$("#transportCompanyName").change(function() {

			var companyName = $("#transportCompanyName option:selected").text();
			$(".supervisionCompanyNameInput").val(companyName);
		});

		//绑定点击物流方事件
		$("#supervisionCompanyName").change(function() {

			var companyName = $("#supervisionCompanyName option:selected").text();
			$(".supervisionCompanyNameInput").val(companyName);
		});
	}

	var changeProcessColor = function() {
		//融资动态颜色背景改变
		var status1 = $('#accountProcessBody').find('.div1').find('.div11').find('.span1').html();
		var status2 = $('#accountProcessBody').find('.div2').find('.div11').find('.span1').html();
		var status3 = $('#accountProcessBody').find('.div3').find('.div11').find('.span1').html();
		var status4 = $('#accountProcessBody').find('.div4').find('.div11').find('.span1').html();
		if (status4 == '未开始') {
			$('.content4').find('.tab3').find('.div4').find('img').first().attr('src', '../../../res/png/round_ed.png');
			$('.content4').find('.tab3').find('.div4').css({
				'background': 'url(../../../res/png/line_last.png) no-repeat',
				'color': '#B4B9BE'
			});
			if (status3 == '未开始') {
				$('.content4').find('.tab3').find('.div3').find('img').first().attr('src', '../../../res/png/round_ed.png');
				$('.content4').find('.tab3').find('.div3').css({
					'background': 'url(../../../res/png/line_will.png) repeat-y',
					'color': '#B4B9BE'
				});
				if (status2 == '未开始') {
					$('.content4').find('.tab3').find('.div2').find('img').first().attr('src', '../../../res/png/round_ed.png');
					$('.content4').find('.tab3').find('.div2').css({
						'background': 'url(../../../res/png/line_will.png) repeat-y',
						'color': '#B4B9BE'
					});
					if (status1 == '未开始') {
						$('.content4').find('.tab3').find('.div1').find('img').first().attr('src', '../../../res/png/round_ed.png');
						$('.content4').find('.tab3').find('.div1').css({
							'background': 'url(../../../res/png/line_will.png) repeat-y',
							'color': '#B4B9BE'
						});
					} else {
						$('.content4').find('.tab3').find('.div1').find('img').first().attr('src', "../../../res/png/round_ing.png");
						$('.content4').find('.tab3').find('.div1').css({
							'background': 'url(../../../res/png/line_ing.png) repeat-y',
							'color': '#28BF85'
						});
					}
				} else {
					$('.content4').find('.tab3').find('.div2').find('img').first().attr('src', "../../../res/png/round_ing.png");
					$('.content4').find('.tab3').find('.div2').css({
						'background': 'url(../../../res/png/line_ing.png) repeat-y',
						'color': '#28BF85',
						'padding-bottom': '17px'
					});
					$('.content4').find('.tab3').find('.div1').find('img').first().attr('src', "../../../res/png/round_ed.png");
					$('.content4').find('.tab3').find('.div1').css({
						'background': 'url(../../../res/png/line_ed.png) repeat-y',
						'color': '#878787'
					});
					$('.content4').find('.tab3').find('.div1').find('div').last().css({
						'color': '#878787',
						'border-bottom': 'solid #E3E3E3 2px',
						'padding-bottom': '17px'
					});
				}
			} else {
				$('.content4').find('.tab3').find('.div3').find('img').first().attr('src', "../../../res/png/round_ing.png");
				$('.content4').find('.tab3').find('.div3').css({
					'background': 'url(../../../res/png/line_ing.png) repeat-y',
					'color': '#28BF85',
					'padding-bottom': '17px'
				});
				$('.content4').find('.tab3').find('.div2').find('img').first().attr('src', "../../../res/png/round_ed.png");
				$('.content4').find('.tab3').find('.div2').css({
					'background': 'url(../../../res/png/line_ed.png) repeat-y',
					'color': '#878787'
				});
				$('.content4').find('.tab3').find('.div2').find('div').last().css({
					'color': '#878787',
					'border-bottom': 'solid #E3E3E3 2px',
					'padding-bottom': '17px'
				});
				$('.content4').find('.tab3').find('.div2').find('.span1').find('img').attr('src', "../../../res/png/point_ed.png");
			}
		} else {
			$('.content4').find('.tab3').find('.div4').find('img').first().attr('src', "../../../res/png/round_ing.png");
			$('.content4').find('.tab3').find('.div4').css({
				'background': 'url(../../../res/png/line_last.png) no-repeat',
				'color': '#28BF85'
			});
			$('.content4').find('.tab3').find('.div3').find('img').first().attr('src', "../../../res/png/round_ed.png");
			$('.content4').find('.tab3').find('.div3').css({
				'background': 'url(../../../res/png/line_ed.png) repeat-y',
				'color': '#878787'
			});
			$('.content4').find('.tab3').find('.div3').find('div').last().css({
				'color': '#878787',
				'border-bottom': 'solid #E3E3E3 2px',
				'padding-bottom': '17px'
			});
		}

		var divarray = $('.content4').find('.tab3').find('div').find('div');
		var flag;
		for (var i = 0, j = divarray.length; i < j; i++) {
			if ($(divarray[i]).find('.span3').html() == '' && $(divarray[i]).find('.span1').html() != '' && $(divarray[i]).find('.span2').html() == '' && $(divarray[i]).find('.span4').html() != '') {
				$(divarray[i]).find('.span1').css({
					'color': '#595959',
					'font-weight': 'bold',
					'font-size': '13px',
					'width': '535px'
				});
				$(divarray[i]).find('.span2').css({
					'width': '0'
				});
				$(divarray[i]).find('.span3').css({
					'width': '0'
				});
				$(divarray[i]).find('.span4').css({
					'color': '#595959',
					'width': '142px'
				});
				$(divarray[i]).css({
					'border-top': 'solid #E3E3E3 1px',
					'padding-top': '12px',
					'padding-bottom': '12px',
					'margin-bottom': '0'
				});
				flag = i;
			}
		}
		$(divarray[flag]).css({
			'border-bottom': 'solid #E3E3E3 1px',
			'padding-bottom': '12px'
		});

	};

	return {
		init: init
	};
});